package leetcodecompetition.D355;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author: Siantar
 * @Date: 2023-07-23-10:50
 * @Description: 1.0
 */
public class T6915 {
    public long maxArrayValue(int[] nums) {
        long res = 0, t = 0;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (t >= nums[i]) {
                t += nums[i];
            } else {
                res = Math.max(res, t);
                t = nums[i];
            }
        }
        res = Math.max(res, t);
        return res;
    }
}
